from User import User, JobModule
from Manage import Manage
from Verification import Verification
from DBUtility import DBManage


def systems():
    db = DBManage()
    job_module = JobModule()
    user = User(job_module)
    manage = Manage()
    verification = Verification()
    while True:

        choice = input("""\033[36m 
        欢迎使用铭宇公司系统
           1.管理端
           2.用户端
           0.退出
        请选择操作：\033[0m""")
        if choice == '1':
            account = input("请输入管理员账号:")
            password = input("请输入密码:")
            try:
                if verification.login_verify('tb_admin', account, password):
                    print('登陆成功！')
                    manage.main_view()
            except Exception as e:
                print(f'\033[31m{e}\033[0m')
        elif choice == '2':
            user.main_view()
        elif choice == '0':
            db.close()  # 关闭资源
            exit()
        else:
            print("\033[31m无效选择，请重新输入！\033[0m")


if __name__ == '__main__':
    systems()
